//
//  YCCommentModel.m
//  YCSchool
//
//  Created by gmall on 16/5/13.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCCommentModel.h"

@implementation YCCommentModel
- (CGFloat)l_rowHeight
{
    //    static dispatch_once_t onceToken;
    //    dispatch_once(&onceToken, ^{
    //
    //        __block CGFloat lineSpace = 3;
    //        [GOAdapter performOtherBlock:^{
    //            lineSpace = 3;
    //        } IPhone6Block:^{
    //            lineSpace = 6;
    //        } IPhone6pBlock:^{
    //            lineSpace = 8;
    //        }];
    //
    //        NSString *contentString = @"";
    //
    //        if ([self.level isEqualToString:@"1"])
    //        {
    //            contentString = [NSString stringWithFormat:@"%@: %@",self.fromUserNickname,self.commentContent];
    //        }
    //        else
    //        {
    //            contentString = [NSString stringWithFormat:@"%@ 回复 %@: %@",self.fromUserNickname,self.toUserNickname,self.commentContent];
    //        }
    //
    //        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    //        [paragraphStyle setLineSpacing:lineSpace];
    //        paragraphStyle.lineBreakMode =  NSLineBreakByCharWrapping;
    //
    //        NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:contentString attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:12]}];
    //
    //        _l_rowHeight = [content boundingRectWithSize:CGSizeMake(GO_IPHONE_WIDTH-75-20, CGFLOAT_MAX)
    //                                                      options:NSStringDrawingUsesLineFragmentOrigin
    //                                             context:nil].size.height + 6;
    //
    //    });
    
    NSString *contentString = @"";
    contentString = [NSString stringWithFormat:@"%@: %@",self.uname,self.content];
//    if ([self.level isEqualToString:@"1"])
//    {
//        contentString = [NSString stringWithFormat:@"%@: %@",self.fromUserNickname,self.commentContent];
//    }
//    else
//    {
//        contentString = [NSString stringWithFormat:@"%@ 回复 %@: %@",self.fromUserNickname,self.toUserNickname,self.commentContent];
//    }
    
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineBreakMode =  NSLineBreakByCharWrapping;
    
    NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:contentString attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:13]}];
    
    _l_rowHeight = [content boundingRectWithSize:CGSizeMake(kScreenWidth-75-20, CGFLOAT_MAX)
                                         options:NSStringDrawingUsesLineFragmentOrigin
                                         context:nil].size.height+12;
    
    return _l_rowHeight;
}

@end
